<?php


namespace App\Http\Controllers\admin\validate;

use Illuminate\Support\Facades\Validator;

/**
 * 账号中心验证器
 * Class AccountCenter
 * @package App\Http\Controllers\admin\validate
 */
class AccountCenter
{


    public static function getLoginCode($param){
        $rules = [
            'phone'=> ['required','regex:/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/'],
        ];

        $msg = [
            'phone.required'=>'手机号为空',
            'phone.regex'=>'必须为手机号格式',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function codeLogin($param){
        $rules = [
            'phone'=>['required','regex:/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/'],
            'code'=>'required|numeric',
            'lastIp'=>'required|ip'
        ];
        $msg = [
            'phone.required'=>'手机号为空',
            'phone.regex'=>'必须为手机号格式',
            'code.required'=>'验证码不能为空',
            'code.numeric'=>'验证码必须为数字',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function register($param){
        $rules = [
            'username'=>'required|max:50',
            'type_id'=>'required',
            'phone'=>['required','regex:/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/'],
            'code'=>'required|numeric',
            'password'=>'required|between:6,16',
            'password2'=>'required|between:6,16',
            'lastIp'=>'required|ip'
        ];

        $msg = [
            'username.required'=>'用户名为空',
            'username.max'=>'用户名长于50位',
            'type_id.required'=>'类型为空',
            'phone.required'=>'手机号为空',
            'phone.regex'=>'必须为手机号格式',
            'code.required'=>'验证码不能为空',
            'code.numeric'=>'验证码必须为数字',
            'password.required'=>'密码不能为空',
            'password.between'=>'密码必须大于6位小于等于16位',
            'password2.required'=>'确认密码不能为空',
            'password2.between'=>'确认密码必须大于6位小于等于16位',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
        ];

        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function getCode($param){
        $rules = [
            'phone'=> ['required','regex:/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/'],
        ];

        $msg = [
            'phone.required'=>'手机号为空',
            'phone.regex'=>'必须为手机号格式',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function login($param){
        $rules = [
            'username'=>'required|max:50',
            'password'=>'required|between:6,16',
            'lastIp'=>'required|ip',
        ];

        $msg = [
            'username.required'=>'用户名为空',
            'username.max'=>'用户名长于50位',
            'password.required'=>'密码不能为空',
            'password.between'=>'密码必须大于6位小于等于16位',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function loginOut($param){
        $rules = [
            'userId'=>'required|numeric',
            'lastIp'=>'required|ip'
        ];

        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function queryAdminAll($param){
        $rules = [
            'userId'=>'required|numeric',
            'type'=>'required|numeric',
            'startSize'=>'required|numeric',
            'pageSize'=>'required|numeric'
        ];

        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'type.required'=>'类型为空',
            'type.numeric'=>'类型格式不对',
            'startSize.required'=>'当前页为空',
            'startSize.numeric'=>'当前页格式不对',
            'pageSize.required'=>'页面显示数为空',
            'pageSize.numeric'=>'页面显示数格式不对',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function queryPersonalInfo($param){
        $rules = [
            'id'=>'required|numeric'
        ];

        $msg = [
            'id.required'=>'编号为空',
            'id.numeric'=>'编号格式不对'
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function editPersonalInfo($param){
        $rules = [
            'userId'=>'required|numeric',
            'id'=>'required|numeric',
            'lastIp'=>'required|ip',
            
            'username'=>'required',
            'email'=>'required|email',
            'mobile'=>['required','regex:/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/'],
            'nickname'=>'required',
        ];

        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'id.required'=>'编号格式不对',
            'id.numeric'=>'编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
            'username.required'=>'用户名为空',
            'email.required'=>'邮箱为空',
            'email.email'=>'邮箱格式不对',
            'mobile.required'=>'手机号为空',
            'mobile.regex'=>'手机号格式不对',
            'nickname.required'=>'昵称为空',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function disableAdmin($param){
        $rules = [
            'userId'=>'required|numeric',
            'id'=>'required|numeric',
            'lastIp'=>'required|ip',
            'type'=>'required|numeric',
        ];

        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'id.required'=>'编号格式不对',
            'id.numeric'=>'编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
            'type.required'=>'类型为空',
            'type.numeric'=>'类型格式不对',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function examineAdmin($param){
        $rules = [
            'userId'=>'required|numeric',
            'id'=>'required|numeric',
            'lastIp'=>'required|ip',
            'status'=>'required|numeric',
        ];

        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'id.required'=>'编号格式不对',
            'id.numeric'=>'编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
            'status.required'=>'类型为空',
            'status.numeric'=>'类型格式不对',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function queryAdminLog($param){
        $rules = [
            'userId'=>'required|numeric',
            'type'=>'required|numeric',
            'startSize'=>'required|numeric',
            'pageSize'=>'required|numeric'
        ];

        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'type.required'=>'类型为空',
            'type.numeric'=>'类型格式不对',
            'startSize.required'=>'当前页为空',
            'startSize.numeric'=>'当前页格式不对',
            'pageSize.required'=>'页面显示数为空',
            'pageSize.numeric'=>'页面显示数格式不对',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function queryEmpowerInfo($param){
        $rules = [
            'userId'=>'required|numeric',
            'type'=>'required|numeric',
            'startSize'=>'required|numeric',
            'pageSize'=>'required|numeric'
        ];

        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'type.required'=>'类型为空',
            'type.numeric'=>'类型格式不对',
            'startSize.required'=>'当前页为空',
            'startSize.numeric'=>'当前页格式不对',
            'pageSize.required'=>'页面显示数为空',
            'pageSize.numeric'=>'页面显示数格式不对',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function empowerExamine($param){
        $rules = [
            'userId'=>'required|numeric',
            'type'=>'required|numeric',
            'id'=>'required|numeric',
            'lastIp'=>'required|ip',
        ];

        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'type.required'=>'类型为空',
            'type.numeric'=>'类型格式不对',
            'id.required'=>'编号格式不对',
            'id.numeric'=>'编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',

        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function queryTeacherInfo($param){
        $rules = [
            'userId'=>'required|numeric',
            'type'=>'required|numeric',
            'startSize'=>'required|numeric',
            'pageSize'=>'required|numeric'
        ];

        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'type.required'=>'类型为空',
            'type.numeric'=>'类型格式不对',
            'startSize.required'=>'当前页为空',
            'startSize.numeric'=>'当前页格式不对',
            'pageSize.required'=>'页面显示数为空',
            'pageSize.numeric'=>'页面显示数格式不对',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function uploadAvatar($param){
        $rules = [
            'userId'=>'required|numeric',
            'lastIp'=>'required|ip',
            'file'=>'required|file'
        ];
        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
            'file.required'=>'图片为空',
            'file.file'=>'图片格式不对',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function queryPushLog($param){
        $rules = [
            'userId'=>'required|numeric',
            'type'=>'required|numeric',
            'startSize'=>'required|numeric',
            'pageSize'=>'required|numeric'
        ];

        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'type.required'=>'类型为空',
            'type.numeric'=>'类型格式不对',
            'startSize.required'=>'当前页为空',
            'startSize.numeric'=>'当前页格式不对',
            'pageSize.required'=>'页面显示数为空',
            'pageSize.numeric'=>'页面显示数格式不对',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function queryGroup($param){
        $rules = [
            'type'=>'required|numeric',
            'startSize'=>'required|numeric',
            'pageSize'=>'required|numeric'
        ];

        $msg = [
            'type.required'=>'类型为空',
            'type.numeric'=>'类型格式不对',
            'startSize.required'=>'当前页为空',
            'startSize.numeric'=>'当前页格式不对',
            'pageSize.required'=>'页面显示数为空',
            'pageSize.numeric'=>'页面显示数格式不对',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function queryIdGroup($param){
        $rules = [
            'id'=>'required|numeric'
        ];

        $msg = [
            'id.required'=>'编号为空',
            'id.numeric'=>'编号格式不对'
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function editGroup($param){
        $rules = [
            'userId'=>'required|numeric',
            'id'=>'required|numeric',
            'lastIp'=>'required|ip',
            'title'=>'required',
            'roule'=>'required',
        ];

        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'id.required'=>'编号格式不对',
            'id.numeric'=>'编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
            'title.required'=>'权限名称为空',
            'roule.required'=>'权限组为空',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function retrievePassword($param){
        $rules = [
            'mobile'=>['required','regex:/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/'],
            'password'=>'required|between:6,16',
            'smsCode'=>'required'
        ];

        $msg = [
            'mobile.required'=>'手机号为空',
            'mobile.regex'=>'手机号格式不对',
            'password.required'=>'密码为空',
            'password.between'=>'密码长度小于6位或大于16位',
            'smsCode.required'=>'验证码为空'
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }
}